using System;
using System.IO;
using System.Reflection;

namespace NotifiableLinqTests.MetaGenerator
{
	public class TargetDefinition
	{
		public string ValueProvider;

		public string Name;
		Type _observableEnumerable;
		public string FrameworkPath;
		public string ObservableEnumerableTypeName;
		public string RuntimeDllPath;
		public string[] AdditionalFiles;
		public string RuntimeDllName
		{
			get { return Path.GetFileName(RuntimeDllPath); }
		}

		public Type ObservableEnumerable
		{
			get { return _observableEnumerable ?? (_observableEnumerable = Type.GetType(ObservableEnumerableTypeName)); }
		}

		public Assembly Assembly { get; private set; }

		public void Initialize()
		{
			var asm = Assembly = Assembly.LoadFrom(RuntimeDllPath);
			_observableEnumerable = asm.GetType(ObservableEnumerableTypeName, true);
			if (ObservableEnumerable == null)
			{
				throw new Exception("ObservableEnumerable not found.");
			}
		}
	}
}